<template>
  <div>
       <!-- 账户 -->
  <el-table
    :data="tableData"
    style="width: 100%">
    <el-table-column
      label="日期"
      width="180">
      <template slot-scope="scope">
        <i class="el-icon-time"></i>
        <span style="margin-left: 10px">{{ scope.row.date }}</span>
      </template>
    </el-table-column>
    <el-table-column
      label="姓名"
      width="180">
      <template slot-scope="scope">
        <el-popover trigger="hover" placement="top">
          <p>姓名: {{ scope.row.username }}</p>
          <div slot="reference" class="name-wrapper">
            <el-tag size="medium">{{ scope.row.username }}</el-tag>
          </div>
        </el-popover>
      </template>
    </el-table-column>
    <el-table-column
      label="账号"
      width="180">
      <template slot-scope="scope">
        <el-popover trigger="hover" placement="top">
          <p>账号: {{ scope.row.phoneNumber }}</p>
          <div slot="reference" class="name-wrapper">
            <el-tag size="medium">{{ scope.row.phoneNumber }}</el-tag>
          </div>
        </el-popover>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row._id)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  <div>
      <template><xiug v-show="xs"/></template>
  </div>
  </div>

</template>
<script>
import axios from "axios"
import xiug from './xiug.vue'
  export default {
    data() {
      return {
        tableData: [{
          date: '2016-05-02',
          name: '王小虎',
          num:'15154811254'
        }, {
          date: '2016-05-04',
          name: '王小虎',
           num:'15154811254'
        }, {
          date: '2016-05-01',
          name: '王小虎',
          num:'15154811254'
        }, {
          date: '2016-05-03',
          name: '王小虎',
          num:'15154811254'
        }],
        labV:{
            username:'',
            phone:'',
            yesN:''
        },
        xs:false,
      }
    },
    components:{xiug},
    methods: {
      handleEdit(index, row) {
        // console.log(index, row);
        alert('确认修改么？')
       this.xs =!this.xs
        

      },
      async handleDelete(index, row) {
        console.log(index, row);
        alert('确定要删除')
        this.tableData.splice(index,1)
        // console.log(row)
        let d =await axios.get("http://localhost:3000/api/v3/deleteService/"+row)


      }
    },
    async mounted(){
      let data = await axios.get("http://localhost:3000/api/v3/serviceList");
      data = data.data.data
      this.tableData = data
      console.log(this.tableData)
    }
  }
</script>

<style lang="scss" scoped>
  .boxlab{
      width: 300px;
      height: 200px;
      background: pink;
      position: fixed;
      top: 400px;
      left: 500px;
      z-index: 50;
  }
  .boxlab input{
      margin-top: 20px;
  }
</style>